<template>
  <a-card :bordered='false' class='card-area'>
    <!-- 查询区域 11111-->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' :label-col='labelCol' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :md='6' :sm='8'>
            <a-form-item label='客户名称'>
              <a-input placeholder='请输入客户名称' v-model='queryParam.patientName'></a-input>
            </a-form-item>
          </a-col>

          <a-col :md='5' :sm='8'>
            <a-form-item label='事件类型'>
              <a-select v-model='queryParam.monitorType' placeholder='请选择事件类型'>
                <a-select-option value=''>请选择</a-select-option>
                <a-select-option value='1'>心血管测评</a-select-option>
                <a-select-option value='2'>身体测量</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :md='5' :sm='8'>
            <a-form-item label='处理状态'>
              <a-select v-model='queryParam.status' placeholder='请选择监控状态'>
                <a-select-option value=''>请选择</a-select-option>
                <a-select-option value='0'>待处理</a-select-option>
                <a-select-option value='1'>处理中</a-select-option>
                <a-select-option value='2'>处理完成</a-select-option>
                <a-select-option value='3'>不需处理</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
           <a-col :md='6' :sm='24'>
               <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
               <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class='table-operator'>

    </div>

    <!-- table区域-begin -->
    <div>

        <a-table
          ref='table'
          size='middle'
          bordered
          rowKey='id'
          :columns='columns'
          :dataSource='dataSource'
          :pagination='ipagination'
          :loading='loading'
          @change='handleTableChange'>

        <span slot='action' slot-scope='text, record'>
          <a @click='handleView(record)'>查看</a>
          <a-divider type="vertical" v-if="record.status=='1'|| record.status=='0'"/>
          <a @click='handleEdit(record)' v-if="record.status=='1'|| record.status=='0'">处理</a>
        </span>

        </a-table>
      </div>
      <!-- table区域-end -->
    <h-monitor-event-handle-result-modal ref="modalForm"  @ok="modalFormOk"></h-monitor-event-handle-result-modal>
    <h-monitor-event-handle-result-list-model ref="modalView" ></h-monitor-event-handle-result-list-model>
  </a-card>

</template>
<script>
import '@assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { putAction, getAction, postAction } from '@api/manage'
import { frozenBatch } from '@api/api'
import HMonitorEventHandleResultModal from './modules/HMonitorEventHandleResultModal'
import HMonitorEventHandleResultListModel from './modules/HMonitorEventHandleResultListModal'

export default {
  name: 'h_monitor_eventList',
  mixins: [JeecgListMixin],
  components: {
    HMonitorEventHandleResultModal,
    HMonitorEventHandleResultListModel
  },
  data() {
    return {
      description: '健康预警 管理页面',
      labelCol: { style: { width: '110px' } },
      // 表头
      columns: [
        {
          title: '客户名称',
          align: 'center',
          dataIndex: 'patientName'
        },
        {
          title: '事件类型',
          align: 'center',
          dataIndex: 'monitorType',
          customRender: function(t, r, index) {
            //监控KEY 1 心血管测评结果 2 血压  3血糖 4尿酸
            if (t == '1') {
              return '心血管测评 '
            } else if (t == '2') {
              return '血压测量'
            } else if (t == '3') {
              return '血糖测量'
            }else if (t == '4') {
              return '尿酸测量'
            }
            return ''
          }
        },
        {
          title: '数据来源',
          align: 'center',
          dataIndex: 'monitorSource',
        },
        {
          title: '设备型号',
          align: 'center',
          dataIndex: 'monitorDevice',
          customRender: function (text, record, index) {
            return text==""?"~":text;
          }
        },
        {
          title: '告警内容',
          align: 'left',
          width: 500,
          dataIndex: 'itemList',
          customRender: function (text, record, index) {
            let textStr = '';
            console.log(record.itemList)
            record.itemList.forEach((item, index)=>{
              textStr+=item.indexName+"："+item.value+ '\n'
            });

            const answer = textStr.split('\n')
            return answer.map((item) => {
              return <li>{item}</li>
            })
          },
        },
        {
          title: '告警时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        {
          title: '处理状态',
          align: 'center',
          dataIndex: 'status',
          customRender: function(t, r, index) {
            //监控状态 0待处理 1处理中  2处理完成  3不需处理
            if (t == '0') {
              return '待处理 '
            } else if (t == '1') {
              return '处理中'
            } else if (t == '2') {
              return '处理完成'
            }
            return '不需处理'
          }
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/patient/monitor/record/list',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>